﻿<inter:PluginConfigForm x:Class="Convertor.Plugin.DispatchTemplate.ConfigForm"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             xmlns:sm="clr-namespace:Wpf.CommonTools.SystemExtension;assembly=Wpf.CommonTools"
             xmlns:conv="clr-namespace:Wpf.CommonTools.Converter;assembly=Wpf.CommonTools"
             xmlns:inter="clr-namespace:Convertor.Interface;assembly=Convertor.Interface"
             xmlns:local="clr-namespace:Convertor.Plugin.DispatchTemplate"
             xmlns:sys="clr-namespace:System;assembly=mscorlib"
             mc:Ignorable="d">
    <inter:PluginConfigForm.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="/Convertor;component\Assets\Style.xaml"/>
                <ResourceDictionary Source="/Convertor;component\Assets\Lang\StringResource.en.xaml"/>
                <ResourceDictionary Source="Assets\Lang\StringResource.zh.xaml"/>
                <ResourceDictionary Source="Assets\Lang\StringResource.en.xaml"/>
            </ResourceDictionary.MergedDictionaries>
            <local:TemplateListBGColorConverter x:Key="TemplateListBGColorConverter"/>
        </ResourceDictionary>
    </inter:PluginConfigForm.Resources>

    <DockPanel DataContext="{Binding RelativeSource={RelativeSource AncestorType=inter:PluginConfigForm, Mode=FindAncestor}, Path=Config}">
        <WrapPanel DockPanel.Dock="Top">
            <Button Content="{DynamicResource Clear}" Click="Clear_Click" />
        </WrapPanel>
        <AdornerDecorator DockPanel.Dock="Top">
            <Border>
                <ListBox x:Name="lstTemplate" MinWidth="400" MinHeight="200" MaxHeight="400" MaxWidth="600"
                         Margin="5"
                  
                     ItemsSource="{Binding RelativeSource={RelativeSource AncestorType=inter:PluginConfigForm, Mode=FindAncestor}, Path=AllTemplate}"
                     SelectedItem="{Binding Path=TempModel, UpdateSourceTrigger=PropertyChanged}">
                    <ListBox.ItemTemplate>
                        <DataTemplate>
                            <TextBlock  Text="{Binding Path=Name}" ToolTip="{Binding Path=Description}">
                                <TextBlock.Foreground>
                                    <MultiBinding Converter="{StaticResource TemplateListBGColorConverter}">
                                        <Binding RelativeSource="{RelativeSource AncestorType=inter:PluginConfigForm, Mode=FindAncestor}" Path="Config.UniqueId"/>
                                        <Binding Path="."/>
                                    </MultiBinding>
                                </TextBlock.Foreground>
                            </TextBlock>
                        </DataTemplate>
                    </ListBox.ItemTemplate>
                    <sm:WatermarkService.Titlemark>
                        <TextBlock Text="{DynamicResource TemplateList}" TextAlignment="Right" VerticalAlignment="Bottom" Margin="0,0,20,20"></TextBlock>
                    </sm:WatermarkService.Titlemark>
                </ListBox>
            </Border>
        </AdornerDecorator>
        <TextBlock Style="{StaticResource InfoStyle}" DockPanel.Dock="Top" Text="{Binding Path=ToolTip}"/>
    </DockPanel>
</inter:PluginConfigForm>
